home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1995 October / EnigmA AMIGA RUN 01 (1995)(G.R. Edizioni)(IT)[!][issue 1995-10][Aminet 7].iso / Aminet / dev / gui / DesignerV1_53.lha / Designer / SuperBitMapDemo / SuperBitMapDemo.c < prev    next >
C/C++ Source or Header  |  1995-04-28  |  2KB  |  112 lines

  1. /* Compile me to get full executable. */
  2.  
  3. #include <stdio.h>
  4. #include "superbitmapdemowin.c"
  5.  
  6. BOOL inbox(void)
  7. {
  8. return ( 
  9.         (SBWin->MouseX-SBWin->BorderLeft > 7  ) &&  
  10.         (SBWin->MouseX-SBWin->BorderLeft < 275) &&  
  11.         (SBWin->MouseY-SBWin->BorderTop  > 38 ) &&  
  12.         (SBWin->MouseY-SBWin->BorderTop  < 145)
  13.         );
  14. }
  15.  
  16. UWORD   oldx;
  17. UWORD   oldy;
  18. UWORD   newx;
  19. UWORD   newy;
  20.  
  21. int main(void)
  22. {
  23. int done=0;
  24. ULONG class;
  25. UWORD code;
  26. struct Gadget *pgsel;
  27. struct IntuiMessage *imsg;
  28. struct Border myborder = {0,0,1,0,JAM1,2,(WORD *)&oldx,NULL};
  29. BOOL drawing = FALSE;
  30.  
  31. oldx = 65535;
  32. oldy = 65535;
  33. if (OpenLibs()==0)
  34.     {
  35.     if (OpenWindowSBWin( (UBYTE *)"DesignerDemoPubScreen" )==0)
  36.         {
  37.         while(done==0)
  38.             {
  39.             Wait(1L << SBWin->UserPort->mp_SigBit);
  40.             imsg=GT_GetIMsg(SBWin->UserPort);
  41.             while (imsg != NULL )
  42.                 {
  43.                 class=imsg->Class;
  44.                 code=imsg->Code;
  45.                 pgsel=(struct Gadget *)imsg->IAddress; /* Only reference if it is a gadget message */
  46.                 GT_ReplyIMsg(imsg);
  47.                 if (class==IDCMP_CLOSEWINDOW)
  48.                     done=1;
  49.                 if (class==IDCMP_REFRESHWINDOW)
  50.                     {
  51.                     GT_BeginRefresh(SBWin);
  52.                     GT_EndRefresh(SBWin, TRUE);
  53.                     }
  54.                 if (class == IDCMP_GADGETUP)
  55.                     {
  56.                     if (pgsel->GadgetID == ColourGadget)
  57.                         {
  58.                         myborder.FrontPen = code;
  59.                         }
  60.                     }
  61.                 if (class == IDCMP_MOUSEBUTTONS)
  62.                     {
  63.                     if (code== SELECTUP)
  64.                         {
  65.                         drawing = FALSE;
  66.                         }
  67.                     else
  68.                         {
  69.                         if ( inbox() )
  70.                             {
  71.                             drawing = TRUE;
  72.                             oldx = SBWin->MouseX-SBWin->BorderLeft;
  73.                             oldy = SBWin->MouseY-SBWin->BorderTop;
  74.                             }
  75.                         }
  76.                     }
  77.                 if (class == IDCMP_MOUSEMOVE )
  78.                     {
  79.                     if (drawing==TRUE)
  80.                         {
  81.                         if ( inbox() )
  82.                             {
  83.                             newx = SBWin->MouseX-SBWin->BorderLeft;
  84.                             newy = SBWin->MouseY-SBWin->BorderTop;
  85.                             if ( oldx != 65535 )
  86.                                 {
  87.                                 DrawBorder(SBWin->RPort,(struct Border *)&myborder,0,0);
  88.                                 }
  89.                             oldx = newx;
  90.                             oldy = newy;
  91.                             }
  92.                         else
  93.                             {
  94.                             oldx = 65535;
  95.                             oldy = 65535;
  96.                             }
  97.                         }
  98.                     }
  99.                 imsg=GT_GetIMsg(SBWin->UserPort);
  100.                 }
  101.             }
  102.         
  103.         CloseWindowSBWin();
  104.         }
  105.     else
  106.         printf("Cannot open window.\n");
  107.     CloseLibs();
  108.     }
  109. else
  110.     printf("Cannot open libraries.\n");
  111. }
  112.